package com.cgnpc.scp.manager.controller;

import com.cgnpc.cud.annotation.OperatorType;
import com.cgnpc.cud.annotation.UBA;
import com.cgnpc.cud.core.domain.AjaxResult;
import com.cgnpc.scp.common.bean.MyPageResult;
import com.cgnpc.scp.common.utils.AjaxResultUtil;
import com.cgnpc.scp.manager.mybatis.entity.Debugtips;
import com.cgnpc.scp.manager.mybatis.entity.Milestone;
import com.cgnpc.scp.manager.mybatis.entity.ProcessInfo;
import com.cgnpc.scp.manager.mybatis.entity.Systeminfo;
import com.cgnpc.scp.manager.service.DebugTipService;
import com.cgnpc.scp.manager.service.MilestoneService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/******************************
 * 用途说明: 调试小贴士
 * 作者姓名: heyachen
 * 创建时间: 2020/08/06 23:04
 ******************************/
@Controller
@RequestMapping("/scp/data/milestone")
public class MilestoneController {


    private static final Logger LOGGER = LoggerFactory.getLogger(MilestoneController.class);
    @Autowired
    private MessageSource messageSource;

    @Autowired
    private MilestoneService milestoneService;

    /**********************************
     * 用途说明: 保存信息
     * 参数说明 reqDataDict
     * 返回值说明:
     ***********************************/
    @ApiOperation(value="保存调试小贴士信息")
    @UBA(module = "后台管理", action = "保存调试小贴士", channel = OperatorType.Button)
    @RequestMapping(value = "/save", method = {RequestMethod.POST})
    @ResponseBody
    public Object save(HttpServletRequest request, @RequestBody Milestone reqDataDict) {
        try{
            int updateRows=milestoneService.saveOrUpdate(reqDataDict);
            return AjaxResultUtil.createI18nDefaultSuccess(request,messageSource,updateRows);
        }catch (Exception e){
            LOGGER.error("MilestoneController save error : {}",e.getMessage(),e);
            return AjaxResultUtil.createI18nDefaultError(request,messageSource,e.getMessage());
        }
    }
    /**********************************
     * 用途说明: 查询单条
     * 参数说明  reqDataDict
     * 返回值说明:
     ***********************************/
    @ApiOperation(value="查询单条")
    @UBA(module = "后台管理", action = "调试小贴士详情", channel = OperatorType.Button)
    @RequestMapping(value = "/loadByID", method = {RequestMethod.POST})
    @ResponseBody
    public Object loadByID(HttpServletRequest request, @RequestBody Milestone reqDataDict) {
        try{
            Milestone milestone = milestoneService.loadByID(reqDataDict);
            return AjaxResultUtil.createI18nDefaultSuccess(request,messageSource,milestone);
        }catch (Exception e){
            LOGGER.error("SystemInfoController loadByID error : {}",e.getMessage(),e);
            return AjaxResultUtil.createI18nDefaultError(request,messageSource,e.getMessage());
        }
    }
    /**********************************
     * 用途说明: 删除信息
     * 参数说明 ids
     * 返回值说明:
     ***********************************/
    @ApiOperation(value="删除小贴士信息")
    @UBA(module = "后台管理", action = "删除调试小贴士", channel = OperatorType.Button)
    @RequestMapping(value = "/del", method = {RequestMethod.POST})
    @ResponseBody
    public Object del(HttpServletRequest request, @RequestBody List<String> ids) {
        try{
            int delete = milestoneService.del(ids);
            return AjaxResultUtil.createI18nDefaultSuccess(request,messageSource,delete);
        }catch (Exception e){
            LOGGER.error("MilestoneController del error : {}",e.getMessage(),e);
            return AjaxResultUtil.createI18nDefaultError(request,messageSource,e.getMessage());
        }
    }
    /**********************************
     * 用途说明: 调戏小贴士分页查询
     * 参数说明 ids
     * 返回值说明:
     ***********************************/
    @ApiOperation(value="调戏小贴士分页查询")
    @UBA(module = "后台管理", action = "调试小贴士分页查询", channel = OperatorType.Page)
    @RequestMapping(value = "/loadByPaging", method = {RequestMethod.POST})
    @ResponseBody
    public Object loadByPaging(HttpServletRequest request, @RequestBody Milestone reqDataDict) {
        try{
            MyPageResult<Milestone> milestoneMyPageResult = milestoneService.loadByPaging(reqDataDict);
            return AjaxResultUtil.createI18nDefaultSuccess(request,messageSource,milestoneMyPageResult);
        }catch (Exception e){
            LOGGER.error("MilestoneController loadByPaging error : {}",e.getMessage(),e);
            return AjaxResultUtil.createI18nDefaultError(request,messageSource,e.getMessage());
        }
    }

}
